var e = require;
var t = module;
var n = exports;
var o,
    i =
    (this && this.__extends) ||
    ((o = function(e, t) {
            return (o =
                Object.setPrototypeOf ||
                ({ __proto__: [] }
                    instanceof Array &&
                    function(e, t) {
                        e.__proto__ = t;
                    }) ||
                function(e, t) {
                    for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
                })(e, t);
        }),
        function(e, t) {
            function n() {
                this.constructor = e;
            }
            o(e, t), (e.prototype = null === t ? Object.create(t) : ((n.prototype = t.prototype), new n()));
        }),
    r =
    (this && this.__decorate) ||
    function(e, t, n, o) {
        var i,
            r = arguments.length,
            a = r < 3 ? t : null === o ? (o = Object.getOwnPropertyDescriptor(t, n)) : o;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) a = Reflect.decorate(e, t, n, o);
        else
            for (var s = e.length - 1; 0 <= s; s--)
                (i = e[s]) && (a = (r < 3 ? i(a) : 3 < r ? i(t, n, a) : i(t, n)) || a);
        return 3 < r && a && Object.defineProperty(t, n, a), a;
    },
    a =
    (this && this.__awaiter) ||
    function(e, a, s, c) {
        return new(s = s || Promise)(function(n, t) {
            function o(e) {
                try {
                    r(c.next(e));
                } catch (e) {
                    t(e);
                }
            }

            function i(e) {
                try {
                    r(c.throw(e));
                } catch (e) {
                    t(e);
                }
            }

            function r(e) {
                var t;
                e.done ?
                    n(e.value) :
                    ((t = e.value) instanceof s ?
                        t :
                        new s(function(e) {
                            e(t);
                        })
                    ).then(o, i);
            }
            r((c = c.apply(e, a || [])).next());
        });
    },
    s =
    (this && this.__generator) ||
    function(e, n) {
        var o,
            i,
            r,
            a = {
                label: 0,
                sent: function() {
                    if (1 & r[0]) throw r[1];
                    return r[1];
                },
                trys: [],
                ops: []
            },
            t = { next: s(0), throw: s(1), return: s(2) };
        return (
            "function" == typeof Symbol &&
            (t[Symbol.iterator] = function() {
                return this;
            }),
            t
        );

        function s(t) {
            return function(e) {
                return c([t, e]);
            };
        }

        function c(t) {
            if (o) throw new TypeError("Generator is already executing.");
            for (; a;)
                try {
                    if (
                        ((o = 1),
                            i &&
                            (r =
                                2 & t[0] ?
                                i.return :
                                t[0] ?
                                i.throw || ((r = i.return) && r.call(i), 0) :
                                i.next) &&
                            !(r = r.call(i, t[1])).done)
                    )
                        return r;
                    switch (((i = 0), (t = r ? [2 & t[0], r.value] : t)[0])) {
                        case 0:
                        case 1:
                            r = t;
                            break;
                        case 4:
                            return a.label++, { value: t[1], done: !1 };
                        case 5:
                            a.label++, (i = t[1]), (t = [0]);
                            continue;
                        case 7:
                            (t = a.ops.pop()), a.trys.pop();
                            continue;
                        default:
                            if (!(r = 0 < (r = a.trys).length && r[r.length - 1]) && (6 === t[0] || 2 === t[0])) {
                                a = 0;
                                continue;
                            }
                            if (3 === t[0] && (!r || (t[1] > r[0] && t[1] < r[3]))) {
                                a.label = t[1];
                                break;
                            }
                            if (6 === t[0] && a.label < r[1]) {
                                (a.label = r[1]), (r = t);
                                break;
                            }
                            if (r && a.label < r[2]) {
                                (a.label = r[2]), a.ops.push(t);
                                break;
                            }
                            r[2] && a.ops.pop(), a.trys.pop();
                            continue;
                    }
                    t = n.call(e, a);
                } catch (e) {
                    (t = [6, e]), (i = 0);
                } finally {
                    o = r = 0;
                }
            if (5 & t[0]) throw t[1];
            return { value: t[0] ? t[1] : void 0, done: !0 };
        }
    };
Object.defineProperty(n, "__esModule", { value: !0 });
var c,
    l = e("index"),
    u = e("common"),
    p = cc._decorator,
    t = p.ccclass,
    e = p.property,
    p = p.disallowMultiple,
    p =
    ((c = cc.Component),
        i(h, c),
        (h.prototype.show = function(e, t) {
            void 0 === t && (t = this.animDuration),
                (this.options = e),
                (this.node.active = !0),
                this.init(this.options),
                this.updateDisplay(this.options),
                this.adjustUI(),
                this.playPanelShowAnim(t);
        }),
        (h.prototype.hide = function(e) {
            var t = this;
            u.tempDisableButton(e, 1), u.disableTouch(this.node, !0);
            var n = this.node,
                o = cc
                .tween(this.content)
                .to(0.125, { scale: 1.1 }, { easing: cc.easing.quadOut })
                .parallel(
                    cc.tween(this.content).to(0.25, { scale: 0.5 }, { easing: cc.easing.quadIn }),
                    cc
                    .tween(this.content)
                    .delay(1 / 24)
                    .to(0.25, { opacity: 0 })
                )
                .call(function() {
                    (n.active = !1),
                    t.onHide && t.onHide(),
                        u.disableTouch(t.node, !1),
                        t.finishCallback && t.finishCallback(n, t.returnValue);
                });
            return new Promise(function(e) {
                o.call(function() {
                    e();
                }).start();
            });
        }),
        (h.prototype.init = function() {}),
        (h.prototype.adjustUI = function() {
            var e, t;
            l.platform.canShowBanner() &&
                ((e =
                        (l.platform.getBannerSize().height / l.platform.getSystemData().windowHeight) *
                        cc.view.getVisibleSize().height),
                    null == this.content ||
                    ((t = (cc.view.getVisibleSize().height - cc.view.getDesignResolutionSize().height) / 2) < e &&
                        (this.content.y += e - t)));
        }),
        (h.prototype.updateDisplay = function() {}),
        (h.prototype.onShow = function() {}),
        (h.prototype.onHide = function() {}),
        (h.prototype.setFinishCallback = function(e) {
            this.finishCallback = e;
        }),
        (h.prototype.setReturnValue = function(e) {
            this.returnValue = e;
        }),
        (h.prototype.canShowBanner = function() {
            return a(this, void 0, Promise, function() {
                return s(this, function() {
                    return [2, !0];
                });
            });
        }),
        (h.prototype.playPanelShowAnim = function(e) {
            var t,
                n = this;
            null != this.content ?
                (((t = this.content).active = !0),
                    (t.scale = 0.5),
                    (t.opacity = 0),
                    cc
                    .tween(t)
                    .to(e, { scale: 1, opacity: 255 }, { easing: "backOut" })
                    .call(function() {
                        n.onShow && n.onShow();
                    })
                    .start()) :
                this.onShow && this.onShow();
        }),
        r([e(cc.Node)], h.prototype, "content", void 0),
        r([t, p], h));

function h() {
    var e = (null !== c && c.apply(this, arguments)) || this;
    return (e.content = null), (e.animDuration = 0.5), (e.finishCallback = null), (e.returnValue = null), e;
}
n.default = p;